<?php

function amazon_request($str) {	
	global $amazon_zone, $amazon_api, $amazon_apix;
	
	$amazon_zone="com";
	$amazon_api="AKIAINCVELGD65NBPHOA"; //api key
	$amazon_apix="IeuD0udg7CebzlEcqQhY2MXmahCA1L3xdeozyVmb"; //Secret key
		
	$rest_param = 'Service=AWSECommerceService&AWSAccessKeyId='.$amazon_api.'&'.$str.
			'&Version=2009-01-06&Timestamp='.gmdate("Y-m-d\TH:i:s\Z");
	$rest_param = str_replace(",","%2C",$rest_param);
	$rest_param = str_replace(":","%3A",$rest_param);
	
	$rest_param_arr = explode('&', $rest_param);
	sort($rest_param_arr);
	$rest_param = implode('&', $rest_param_arr);
	
	$rest_prepend = "GET\necs.amazonaws.".$amazon_zone."\n/onca/xml\n".$rest_param;
	$signature = base64_encode(hash_hmac("sha256", $rest_prepend, $amazon_apix, True));
	$signature = urlencode($signature);

	return "http://ecs.amazonaws.".$amazon_zone."/onca/xml?".$rest_param."&Signature=".$signature;
}


$str='ItemId=B0018TBECU&MerchantId=Featured&Operation=ItemLookup&ResponseGroup=Medium%2COfferFull&Sort=titlerank';

echo amazon_request($str);
?>
<iframe width="100%" height="100%" src="<?php echo amazon_request($str); ?>"></iframe>